package com.doit.day03

import scala.util.Sorting

object _03_比较器和可比较的 {
  def main(args: Array[String]): Unit = {

    val orders: Array[ScalaOrder] = Array(
      ScalaOrder("o001", "g002", 9.9, 10),
      ScalaOrder("o002", "g001", 19.9, 29),
      ScalaOrder("o003", "g005", 29.9, 4),
      ScalaOrder("o004", "g004", 92.9, 2),
      ScalaOrder("o005", "g003", 39.9, 1)
    )

    Sorting.quickSort(orders)/*(new Ordering[ScalaOrder] {
      override def compare(x: ScalaOrder, y: ScalaOrder) = x.price.compare(y.price)
    })*/

    orders.foreach(println)



  }

}

case class ScalaOrder(oid:String,gid:String ,price:Double,goodsNum:Int) extends Ordered[ScalaOrder] {
  override def compare(that: ScalaOrder): Int = this.gid.compare(that.gid)
}
